-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[Clang] Remove redundant check for scoped enums in shift operators #152865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang] Remove redundant check for scoped enums in shift operators #152865
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang Author: Timothy Choi (tinnamchoi) ChangesThis check, introduced in 0bf3140, has not been necessary since 21673c4 llvm-project/clang/lib/Sema/SemaExpr.cpp Lines 5432 to 5442 in 0bf3140
llvm-project/clang/lib/AST/Type.cpp Lines 513 to 529 in 21673c4
Full diff: https://github.com/llvm/llvm-project/pull/152865.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6793d6da85cb1..c805ef205beba 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11747,12 +11747,6 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
!RHSType->hasIntegerRepresentation())
return InvalidOperands(Loc, LHS, RHS);
- // C++0x: Don't allow scoped enums. FIXME: Use something better than
- // hasIntegerRepresentation() above instead of this.
- if (isScopedEnumerationType(LHSType) ||
- isScopedEnumerationType(RHSType)) {
- return InvalidOperands(Loc, LHS, RHS);
- }
DiagnoseBadShiftValues(*this, LHS, RHS, Loc, Opc, LHSType);
// "The type of the result is that of the promoted left operand."
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is fine because we don’t treat scoped enums as integer types, but we don’t seem to have any tests for this, so could you add some to make sure that we do reject shifts where one (or both) operands are scoped enums (in C and C++).
What would the tests in C look like? Scoped enums don't exist in C. Other than that, the tests to be introduced in #152698 should cover this, running locally seems fine. llvm-project/clang/test/SemaCXX/enum-scoped.cpp Lines 439 to 452 in 45c8c06
llvm-project/clang/test/SemaCXX/enum-scoped.cpp Lines 580 to 593 in 45c8c06
llvm-project/clang/test/SemaCXX/enum-scoped.cpp Lines 623 to 624 in 45c8c06
|
Yeah, ignore that; I was already tired yesterday and for some reason thought C had them too (it doesn’t; what it does have now is enums with a fixed underlying type, which is probably what I was thinking of)
I mean, it might honestly make more sense then to just integrate this change into that pr seeing as this one is pretty small and you’re basically already refactoring how checking around scoped enums works in the other one. |
I prefer keeping my PRs atomic. All of my changes in that PR are necessary towards the primary goal of that PR, whereas this change wouldn't be. If I allowed myself to make refactors whenever I'm working on a feature it would introduce quite a bit of noise, which seems like a bad habit to have. |
I mean, altenratively we could just wait until the other pr is merged and then merge this one afterwards; I just don’t like the idea of making a non-obvious change if there are no tests at all for it (unless we already have test that I missed but I couldn’t find any). |
Agreed, let's wait for that then. |
@Sirraide The other PR got merged, this should be good upon green CI rerun |
CI failure seems to be due to something in LLDB and it looks like other prs are suffering from the same issue. |
@tinnamchoi Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/23112 Here is the relevant piece of the build log for the reference
|
This check, introduced in 0bf3140, has not been necessary since 21673c4
llvm-project/clang/lib/Sema/SemaExpr.cpp
Lines 5432 to 5442 in 0bf3140
llvm-project/clang/lib/AST/Type.cpp
Lines 513 to 529 in 21673c4